import { createAPI } from '@/api/http';
import { Opts } from '@/api/opts';

/**
 *  @description 添加接口
 *  @name createApis
 *  @param  path 路径 {string} 必传参数
 *  @param  name 接口名 {string} 必传参数
 *  @param  groupName 接口组 {string} 必传参数
 *  @param  method 方法 {string} 必传参数
 *  @param  memo 备注 {string} 

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const createApis = (opts: Opts) =>
  createAPI({
    method: 'post',
    url: '/wit/apis/createApis',
    opts,
  });

/**
 *  @description 删除接口
 *  @name deleteApis
 *  @param  id apis id {string} 必传参数

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const deleteApis = (opts: Opts) =>
  createAPI({
    method: 'delete',
    url: '/wit/apis/deleteApis',
    opts,
  });

/**
 *  @description 通过id获取接口信息
 *  @name getApisById
 *  @param  id apis id {string} 必传参数

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const getApisById = (opts: Opts) =>
  createAPI({
    method: 'get',
    url: '/wit/apis/getApisById',
    opts,
  });

/**
 *  @description 获取接口信息
 *  @name getApisList
 *  @param  pageNum 页码 {integer} 
 *  @param  pageSize 每页数 {integer} 
 *  @param  name 接口名 {string} 
 *  @param  groupName 接口组 {string} 
 *  @param  method 方法 {string} 

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const getApisList = (opts: Opts) =>
  createAPI({
    method: 'get',
    url: '/wit/apis/getApisList',
    opts,
  });

/**
 *  @description 同步Api数据
 *  @name synApis

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const synApis = (opts: Opts) =>
  createAPI({
    method: 'get',
    url: '/wit/apis/synApis',
    opts,
  });

/**
 *  @description 修改接口
 *  @name updateApis
 *  @param  id ID {string} 必传参数
 *  @param  path 路径 {string} 
 *  @param  name 接口名 {string} 
 *  @param  groupName 接口组 {string} 
 *  @param  method 方法 {string} 

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const updateApis = (opts: Opts) =>
  createAPI({
    method: 'put',
    url: '/wit/apis/updateApis',
    opts,
  });
